<%
layout("/layouts/platform.html"){
%>
<div class="panel-body" style="padding-top: 15px;">
	<div class="box">
		<div class="box-body">
			<div class="col-sm-12">
				<div class="row">
			        <table class="table table-bordered table-hover mg-t datatable" style=" white-space: nowrap;
    text-overflow: ellipsis;">
                <thead>
                <tr>
                    <th>用户电话</th>
                    <th>用户类型</th>
                    <th>用户ID</th>
                    <th>所属片区</th>
                    <th>培训项目</th>
                    <th>产品类型</th>
                    <th>产品名称</th>
                    <th>考场地点</th>
                    <th>订单号</th>
                    <th>实际支付金额</th>
                    <th>支付方式</th>
                    <th>支付时间</th>
                    <th>状态</th>
     		        </table>
		        </div>
		    </div>
	    </div>
	</div>
</div>
<script language="JavaScript">
	var datatable;
	function initDatatable() {
	    datatable = $('.datatable').DataTable({
	        "dom": '<"toolbar">frtip',
	        "searching": false,
	        "processing": false,
	        "serverSide": true,
	        "select": true,
	        "ordering": false,
	        "scrollX": true,
	        "language": {
	            "url": "${base}/assets/plugins/datatables/cn.json"
	        },
	        "preDrawCallback": function () {
	            sublime.showLoadingbar($(".main-content"));
	        },
	        "drawCallback": function () {
	            sublime.closeLoadingbar($(".main-content"));
	        },
	        "ajax": {
	            "url": "${base}/platform/train/lumpOrder/data",
	            "type": "post",
	            "data": function (d) {
	            }
	        },
	        "columns": [
	            {"data": "customer_id", "bSortable": true},
	            {"data": "user_type", "bSortable": true},
	            {"data": "user_id", "bSortable": true},
	            {"data": "region_id", "bSortable": true},
	            {"data": "project_id", "bSortable": true},
	            {"data": "product_type", "bSortable": true},
	            {"data": "product_id", "bSortable": true},
	            {"data": "location", "bSortable": true},
	            {"data": "bill_no", "bSortable": true},
	            {"data": "money", "bSortable": true},
	            {"data": "pay_way", "bSortable": true},
	            {"data": "pay_time", "bSortable": true},
	            {"data": "state", "bSortable": true}
	        ],
	        "columnDefs": [
				{
					"render": function (data, type, row) {
				        return getCustomer(data);
				     },
				     "targets": 0
				},
				{
					"render": function (data, type, row) {
						if(data=="weixin"){
							return "微信用户";
						}else{
							return data;
						}
				     },
				     "targets": 1
			 	},
			 	{
					"render": function (data, type, row) {
				        return getRegion(data);
				     },
				     "targets": 3
				},
			 	{
					"render": function (data, type, row) {
				        return getProject(data);
				     },
				     "targets": 4
				},
			 	{
					"render": function (data, type, row) {
				        return getProductType(data);
				     },
				     "targets": 5
				},
				{
					"render": function (data, type, row) {
				        return getProduct(data);
				     },
				     "targets": 6
				},
	         	{
	            	"render": function (data, type, row) {
	                 	if (data) {
	                    	return moment(parseInt(data*1000)).format("YYYY-MM-DD HH:mm:ss");
	                    }
	                   return '';
	                 },
	                 "targets": 11
	             },
	             {
						"render": function (data, type, row) {
							if(data==1){
								return "已支付";
							}else if(data==0){
								return "未支付";
							}else if(data==2){
								return "已退款";
							}
					     },
					     "targets": 12
				 }
	        ]
	    });
	}
	$(function () {
	    initDatatable();
	});
	//获取客户
	function getCustomer(id){
    	var datas="";
    	$.ajax({
			url : "${base}/platform/train/lumpOrder/getCustomer",
			data : {
				id : id
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				datas= data;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    	return datas;
    }
	//获取片区
	function getRegion(id){
    	var datas="";
    	$.ajax({
			url : "${base}/platform/train/lumpOrder/getRegion",
			data : {
				id : id
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				datas= data;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    	return datas;
    }
	//获取项目
	function getProject(id){
    	var datas="";
    	$.ajax({
			url : "${base}/platform/train/lumpOrder/getProject",
			data : {
				id : id
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				datas= data;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    	return datas;
    }
	//获取产品类型
	function getProductType(id){
    	var datas="";
    	$.ajax({
			url : "${base}/platform/train/lumpOrder/getProductType",
			data : {
				id : id
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				datas= data;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    	return datas;
    }
	//获取产品类型
	function getProduct(id){
    	var datas="";
    	$.ajax({
			url : "${base}/platform/train/lumpOrder/getProduct",
			data : {
				id : id
			},
			type : "post",
			async : false,
			dataType : "json",
			success : function(data){
				datas= data;
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				return false;
			}
		});
    	return datas;
    }
	
	
</script>
<%}%>
